home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / windownt / perlnt.zip / t / base / context.nt < prev    next >
Text File  |  1993-07-25  |  703b  |  43 lines

  1.  
  2. print "1..3\n";
  3.  
  4. #
  5. # routines to test the scalar and wantarray context built-ins
  6. #
  7.  
  8. @foo = ('foo', 'bar', 'baz');
  9.  
  10. $bar = "number of elements in foo is " . scalar(@foo);
  11.  
  12. split (/ /, $bar);
  13.  
  14. if ($_[6] eq "3") {print "ok 1\n";} else {print "not ok 1\n";}
  15.  
  16. @foo = &test_wantarray(2, "array");
  17.  
  18. $bar = &test_wantarray(3, "scalar");
  19.  
  20. sub test_wantarray {
  21.     local ($testnum, $type) = @_;
  22.  
  23.     if ($type eq "array") {
  24.     if (wantarray) {
  25.         print "ok $testnum\n";
  26.     } 
  27.     else {
  28.         print "not ok $testnum\n";
  29.     }
  30.     }
  31.     else {
  32.     if (!wantarray) {
  33.         print "ok $testnum\n";
  34.     } 
  35.     else {
  36.         print "not ok $testnum\n";
  37.     }
  38.     }
  39.     return wantarray ? () : "";
  40. }
  41.  
  42.  
  43.